package ar.edu.itba.it.cg.grupo01.impl.gui;

import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.border.Border;

public class ProgressBar {
	
	  JProgressBar pbar;
	  JFrame frame;
	  static final int MY_MINIMUM = 0;
	  static final int MY_MAXIMUM = 100;

	  public ProgressBar()
	  {
	    frame = new JFrame("Allota Render ");
	    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	    
	    Container content = frame.getContentPane();
	    pbar = new JProgressBar();

	    pbar.setMinimum(MY_MINIMUM);
	    pbar.setMaximum(MY_MAXIMUM);
	    pbar.setStringPainted(true);
	    
	    Border border = BorderFactory.createTitledBorder("Rendering...");
	    pbar.setBorder(border);
	    pbar.setValue(0);
	    
	    content.add(pbar, BorderLayout.NORTH);
	    frame.setSize(300, 100);
	    frame.setVisible(true);
	  }
	  
	  public void updateProgressBarValue(int progress)
	  {
		  pbar.setValue(progress);
		  pbar.updateUI();
		  
	  }

	  public void closeWindow()
	  {
		  frame.setVisible(false);
		  frame.dispose();
	  }
}


